/**
*      author: Y_Yao
*      created: 2025-04-14 11:01:27
**/

#include<bits/stdc++.h>

// #define int LL
using namespace std;
using LL = long long;
const LL LLINF = 9e18;
const int INF = 0x3f3f3f3f;
const int N = 2e5 + 5;
int n,m;


struct dsu
{
    int fa[N],sz[N];

    void init()
    {
        for(int i = 1;i <= n;i++)
        {
            fa[i] = i;
            sz[i] = 1;
        }
    }

    int find(int x)
    {
        return fa[x] == x ? x : fa[x] = find(fa[x]);
    }

    void Union(int u,int v)
    {
        u = find(u);
        v = find(v);
        if(u == v) return;
        if(sz[u] > sz[v]) swap(u,v);
        fa[u] = v;
        sz[v] += sz[u];
    }

    int Size(int x)
    {
        return sz[find(x)];
    }
}D,d;

vector<pair<int,int>> E[N],e[N];

void solve()
{

    cin >> n >> m;
    for(int i = 1;i <= m;i++)
    {
        int u,v;
        cin >> u >> v;
        E[max(u,v)].emplace_back(u,v);
        e[min(u,v)].emplace_back(u,v);
    }
    D.init();
    d.init();
    for(int k = 1;k <= n;k++)
    {
        for(auto& [u,v] : E[k]) D.Union(u,v);
        for(auto& [u,v] : e[k]) d.Union(u,v);

        if(D.Size(1) == k)
        {
            cout << d.Size(1) - k << endl;
        }
        else
        {
            cout << -1 << endl;
        }
    }
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    // cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}